From: Keir Fraser Date: Thu, 15 Jan 2009 12:36:29 +0000 (+0000) Subject: xenoprof: The checks in the function passive_domain_do_rdmsr() were X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14014^2~59 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=523540cc9bc3c4c982fd2c5b9d65a96b2c210a36;p=xen.git xenoprof: The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks(). Signed-off-by: Nitin A Kamble Signed-off-by: Jun Nakajima --- diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c index ef5d1227fd..ba58f2116d 100644 --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -38,19 +38,29 @@ static char *cpu_type; extern int is_active(struct domain *d); extern int is_passive(struct domain *d); -int passive_domain_do_rdmsr(struct cpu_user_regs *regs) +static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,int *typep, int *indexp) { - u64 msr_content; - int type, index; struct vpmu_struct *vpmu = vcpu_vpmu(current); - + if ( model == NULL ) + return 0; if ( model->is_arch_pmu_msr == NULL ) return 0; - if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) ) + if ( !model->is_arch_pmu_msr((u64)regs->ecx, typep, indexp) ) return 0; + if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) ) if ( ! model->allocated_msr(current) ) return 0; + return 1; +} + +int passive_domain_do_rdmsr(struct cpu_user_regs *regs) +{ + u64 msr_content; + int type, index; + + if ( !passive_domain_msr_op_checks(regs, &type, &index)) + return 0; model->load_msr(current, type, index, &msr_content); regs->eax = msr_content & 0xFFFFFFFF; @@ -58,23 +68,13 @@ int passive_domain_do_rdmsr(struct cpu_user_regs *regs) return 1; } - int passive_domain_do_wrmsr(struct cpu_user_regs *regs) { u64 msr_content; int type, index; - struct vpmu_struct *vpmu = vcpu_vpmu(current); - if ( model == NULL ) + if ( !passive_domain_msr_op_checks(regs, &type, &index)) return 0; - if ( model->is_arch_pmu_msr == NULL ) - return 0; - if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) ) - return 0; - - if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) ) - if ( ! model->allocated_msr(current) ) - return 0; msr_content = (u32)regs->eax | ((u64)regs->edx << 32); model->save_msr(current, type, index, msr_content);